﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YJKBuildingProfile.YJKBuildingProfile.Forms;
using YArchitech.Controls;
using YArchitech.ProgressBar;
using YArchitech.Revit;
using YArchitech.Revit.RevitExtension;
using YJKArchUtils.Utils;
using YJKRevitBase.WinForm;
using YRevitJig;

namespace YJKBuildingProfile.YJKBuildingProfile
{
	public class BuildingOutlineController
	{
		public BuildingOutlineController(ExternalCommandData commandData)
		{
			this.m_Revit = commandData;
			this.m_Doc = this.m_Revit.Application.ActiveUIDocument.Document;
			this.m_uiDoc = this.m_Revit.Application.ActiveUIDocument;
			this.m_drawJigCurve = new DrawJigCurve(commandData);
		}

		public Result SearchBuildingOutline()
		{
			ProgressBarForm progressBarForm = new ProgressBarForm(11, ProgressBarStyle.Blocks, true);
			progressBarForm.Show(CmdSearchBuildingOutline._hWndRevit);
			ProfileAnalyzer profileAnalyzer = new ProfileAnalyzer(this.m_Revit);
			List<EdgeInfo> lines = new List<EdgeInfo>();
			try
			{
				if (!profileAnalyzer.GetProfiles(this.m_Doc.ActiveView, ref lines, ref progressBarForm))
				{
					progressBarForm.Dispose();
					return Autodesk.Revit.UI.Result.Cancelled;
				}
			}
			catch (Exception)
			{
				progressBarForm.Dispose();
				return Autodesk.Revit.UI.Result.Failed;
			}
			List<Element> selElements = new List<Element>();
			this.DrawLines(lines, ref selElements);
			RevitVersionFuncs.ClearSelection(this.m_Revit.Application.ActiveUIDocument.Selection);
			RevitVersionFuncs.SetSelection(this.m_Revit.Application.ActiveUIDocument.Selection, selElements);
			progressBarForm.RefreshProgressBar();
			YJKMessageBox.Show("搜索完成");
			RevitVersionFuncs.ClearSelection(this.m_Revit.Application.ActiveUIDocument.Selection);
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		public Result EditOutLine(ref string message)
		{
			if (this.m_Doc.ActiveView.SketchPlane == null)
			{
				Transaction transaction = null;
				try
				{
					transaction = new Transaction(this.m_Doc);
					transaction.Start("new work plane");
					Plane plane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(this.m_Doc.ActiveView.ViewDirection, this.m_Doc.ActiveView.Origin);
					SketchPlane sketchPlane = SketchPlane.Create(this.m_Doc, plane);
					this.m_Doc.ActiveView.SketchPlane = sketchPlane;
					transaction.Commit();
				}
				catch (Exception)
				{
					if (transaction != null)
					{
						transaction.RollBack();
					}
					message = "当前视图创建工作平面失败";
					return Autodesk.Revit.UI.Result.Failed;
				}
			}
			EditingInterfaceForm editingInterfaceForm = new EditingInterfaceForm();
			editingInterfaceForm.Show(BuildingOutlineController._hWndRevit);
			int wMsg = 7;
			BuildingOutlineController.SendMessage(BuildingOutlineController._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			Result result = Autodesk.Revit.UI.Result.Cancelled;
			try
			{
				for (;;)
				{
					switch (editingInterfaceForm.CurrentOperateType)
					{
					case EditingInterfaceForm.OperateType.OT_DrawLine:
						result = this.DrawJigLineRefCurve(editingInterfaceForm.IsContinuous);
						break;
					case EditingInterfaceForm.OperateType.OT_DrawRect:
						result = this.DrawJigRectRefCurve();
						break;
					case EditingInterfaceForm.OperateType.OT_DrawArc3Pt:
						result = this.DrawJigArc3PtRefCurve(editingInterfaceForm.IsContinuous);
						break;
					case EditingInterfaceForm.OperateType.OT_DrawArcCenter:
						result = this.DrawJigArcCenterRefCurve();
						break;
					case EditingInterfaceForm.OperateType.OT_SelectRefCurve:
						result = this.SelectRefCurveOutLine();
						break;
					case EditingInterfaceForm.OperateType.OT_SelectRef:
						result = this.SelectReferenceOutLine();
						break;
					case EditingInterfaceForm.OperateType.OT_Delete:
						result = this.DeleteOutLine();
						break;
					}
					if (result == Autodesk.Revit.UI.Result.Cancelled)
					{
						if (!editingInterfaceForm.PickButton)
						{
							break;
						}
						editingInterfaceForm.PickButton = false;
					}
					else if (result == Autodesk.Revit.UI.Result.Failed)
					{
						break;
					}
				}
				this.ClearTagCurves();
			}
			catch (Exception ex)
			{
				this.ClearTagCurves();
				editingInterfaceForm.Close();
				message = ex.Message;
				return Autodesk.Revit.UI.Result.Failed;
			}
			editingInterfaceForm.Close();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public Result ClearOutLine(ref string message)
		{
			try
			{
				this.ClearOutLine();
			}
			catch (Exception ex)
			{
				message = ex.Message;
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private string GetstatusPromptWithLine(int index)
		{
			string result = "选择直线轮廓线的起始点";
			if (index % 2 == 1)
			{
				result = "选择直线轮廓线的终点";
			}
			return result;
		}

		private bool IsContinuous(bool isContinuous)
		{
			return isContinuous && this.m_PickLastPoint != null;
		}

		private Result DrawJigLineRefCurve(bool bIsContinuous)
		{
			try
			{
				for (;;)
				{
					List<Curve> lines = new List<Curve>();
					if (!bIsContinuous)
					{
						this.m_PickLastPoint = null;
					}
					if (this.m_drawJigCurve.DrawJigCurveLine(ref lines, ref this.m_PickLastPoint, this.GetstatusPromptWithLine(0), this.GetstatusPromptWithLine(1)) != null)
					{
						break;
					}
					if (!bIsContinuous)
					{
						this.m_PickLastPoint = null;
					}
					this.DrawLines(lines);
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private string GetstatusPromptWithBox(int index)
		{
			string result = "选择轮廓线矩形的起始点";
			if (index % 2 == 1)
			{
				result = "选择轮廓线矩形的终点";
			}
			return result;
		}

		private Result DrawJigRectRefCurve()
		{
			this.m_PickLastPoint = null;
			try
			{
				for (;;)
				{
					List<Curve> lines = new List<Curve>();
					if (this.m_drawJigCurve.DrawJigCurveRect(ref lines, this.GetstatusPromptWithBox(0), this.GetstatusPromptWithBox(1)) != null)
					{
						break;
					}
					this.DrawLines(lines);
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private string GetstatusPromptWithArc3Pt(int index)
		{
			string result = "选择弧形轮廓线的起始点";
			if (index % 3 == 1)
			{
				result = "选择弧形轮廓线的终点";
			}
			else if (index % 3 == 2)
			{
				result = "选择弧形轮廓线的线上点";
			}
			return result;
		}

		private Result DrawJigArc3PtRefCurve(bool bIsContinuous)
		{
			try
			{
				for (;;)
				{
					List<Curve> lines = new List<Curve>();
					if (!bIsContinuous)
					{
						this.m_PickLastPoint = null;
					}
					if (this.m_drawJigCurve.DrawJigCurveArc3Pt(ref lines, ref this.m_PickLastPoint, this.GetstatusPromptWithArc3Pt(0), this.GetstatusPromptWithArc3Pt(1), this.GetstatusPromptWithArc3Pt(2)) != null)
					{
						break;
					}
					if (!bIsContinuous)
					{
						this.m_PickLastPoint = null;
					}
					this.DrawLines(lines);
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private string GetstatusPromptWithArcCenter(int index)
		{
			string result = "选择弧形轮廓线的圆心";
			if (index % 3 == 1)
			{
				result = "选择弧形轮廓线的起始点";
			}
			else if (index % 3 == 2)
			{
				result = "选择弧形轮廓线的终点";
			}
			return result;
		}

		private Result DrawJigArcCenterRefCurve()
		{
			this.m_PickLastPoint = null;
			try
			{
				for (;;)
				{
					List<Curve> lines = new List<Curve>();
					if (this.m_drawJigCurve.DrawJigCurveArcCenter2Pt(ref lines, this.GetstatusPromptWithArcCenter(0), this.GetstatusPromptWithArcCenter(1), this.GetstatusPromptWithArcCenter(2)) != null)
					{
						break;
					}
					this.DrawLines(lines);
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private Result SelectRefCurveOutLine()
		{
			this.m_PickLastPoint = null;
			Transform identity = Transform.Identity;
			identity.Origin = this.m_Doc.ActiveView.Origin;
			identity.BasisX = this.m_Doc.ActiveView.RightDirection;
			identity.BasisY = this.m_Doc.ActiveView.UpDirection;
			identity.BasisZ = this.m_Doc.ActiveView.ViewDirection;
			Transform inverse = identity.Inverse;
			try
			{
				Curve curve = null;
				while (this.PickRefCurve(ref curve))
				{
					XYZ xyz = curve.GetEndPoint(0);
					xyz = inverse.OfPoint(xyz);
					xyz = identity.OfPoint(new XYZ(xyz.X, xyz.Y, 0.0));
					XYZ xyz2 = curve.GetEndPoint(1);
					xyz2 = inverse.OfPoint(xyz2);
					xyz2 = identity.OfPoint(new XYZ(xyz2.X, xyz2.Y, 0.0));
					if (!Geometry.IsEqual(xyz.DistanceTo(xyz2), 0.0))
					{
						if (curve.GetType() == typeof(Line))
						{
							this.DrawLines(new List<Curve>
							{
								Line.CreateBound(xyz, xyz2)
							});
						}
						else if (curve.GetType() == typeof(Arc))
						{
							Arc arc = curve as Arc;
							XYZ xyz3 = arc.Center;
							xyz3 = inverse.OfPoint(xyz3);
							xyz3 = identity.OfPoint(new XYZ(xyz3.X, xyz3.Y, 0.0));
							if (!Geometry.IsEqual(arc.Normal, this.m_Doc.ActiveView.ViewDirection))
							{
								XYZ xyz4 = xyz;
								xyz = xyz2;
								xyz2 = xyz4;
							}
							double radius = arc.Radius;
							double angle = Geometry.getAngle(xyz3, xyz, this.m_Doc.ActiveView.RightDirection, this.m_Doc.ActiveView.ViewDirection);
							double angle2 = Geometry.getAngle(xyz3, xyz2, this.m_Doc.ActiveView.RightDirection, this.m_Doc.ActiveView.ViewDirection);
							double num = Geometry.BetweenTheAngles(angle, angle2, true);
							XYZ xyz5 = Geometry.RotateTo(xyz - xyz3, num / 2.0, this.m_Doc.ActiveView.ViewDirection);
							XYZ xyz6 = xyz3 + xyz5;
							this.DrawLines(new List<Curve>
							{
								Arc.Create(xyz, xyz2, xyz6)
							});
						}
					}
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private Result SelectReferenceOutLine()
		{
			this.m_PickLastPoint = null;
			Transform identity = Transform.Identity;
			identity.Origin = this.m_Doc.ActiveView.Origin;
			identity.BasisX = this.m_Doc.ActiveView.RightDirection;
			identity.BasisY = this.m_Doc.ActiveView.UpDirection;
			identity.BasisZ = this.m_Doc.ActiveView.ViewDirection;
			Transform inverse = identity.Inverse;
			try
			{
				Curve curve = null;
				while (this.PickEdge(ref curve))
				{
					XYZ xyz = curve.GetEndPoint(0);
					xyz = inverse.OfPoint(xyz);
					xyz = identity.OfPoint(new XYZ(xyz.X, xyz.Y, 0.0));
					XYZ xyz2 = curve.GetEndPoint(1);
					xyz2 = inverse.OfPoint(xyz2);
					xyz2 = identity.OfPoint(new XYZ(xyz2.X, xyz2.Y, 0.0));
					if (!Geometry.IsEqual(xyz.DistanceTo(xyz2), 0.0))
					{
						this.DrawLines(new List<Curve>
						{
							Line.CreateBound(xyz, xyz2)
						});
					}
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private void ClearTagCurves()
		{
			if (this.m_TagCurves.Count == 0)
			{
				return;
			}
			Transaction transaction = new Transaction(this.m_Doc);
			try
			{
				transaction.Start("delete tag curves");
				this.m_Doc.Delete(this.m_TagCurves);
				transaction.Commit();
				this.m_TagCurves.Clear();
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				if (transaction != null && transaction.HasStarted() && !transaction.HasEnded())
				{
					transaction.RollBack();
				}
			}
		}

		private void ClearOutLine()
		{
			Transaction transaction = new Transaction(this.m_Doc);
			transaction.Start("delete outLine");
			foreach (Element element in new FilteredElementCollector(this.m_Doc, this.m_Doc.ActiveView.Id).OfClass(typeof(CurveElement)).ToElements())
			{
				if (!(typeof(DetailLine) != element.GetType()) || !(typeof(DetailArc) != element.GetType()))
				{
					DetailCurve detailCurve = element as DetailCurve;
					if (detailCurve != null && detailCurve.LineStyle.Name.IndexOf(BuildingOutlineController.m_StrLineNamePrefix) != -1)
					{
						try
						{
							this.m_Doc.Delete(element.Id);
						}
						catch (Exception)
						{
						}
					}
				}
			}
			transaction.Commit();
		}

		private Result DeleteOutLine()
		{
			this.m_PickLastPoint = null;
			try
			{
				List<Element> list = new List<Element>();
				while (this.PickOutLine(ref list))
				{
					Transaction transaction = new Transaction(this.m_Doc);
					transaction.Start("delete outLine");
					foreach (Element element in list)
					{
						try
						{
							this.m_Doc.Delete(element.Id);
						}
						catch (Exception)
						{
						}
					}
					transaction.Commit();
				}
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Cancelled;
		}

		private bool PickRefCurve(ref Curve outLineCurve)
		{
			Selection selection = this.m_Revit.Application.ActiveUIDocument.Selection;
			try
			{
				RefCurveFilter refCurveFilter = new RefCurveFilter();
				Reference reference = selection.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1, refCurveFilter, "拾取详图线生成轮廓线");
				DetailCurve detailCurve = this.m_Doc.GetElement(reference) as DetailCurve;
				outLineCurve = detailCurve.GeometryCurve;
			}
			catch (Exception)
			{
				return false;
			}
			return true;
		}

		private bool PickOutLine(ref List<Element> outLineList)
		{
			Selection selection = this.m_Revit.Application.ActiveUIDocument.Selection;
			RevitVersionFuncs.ClearSelection(selection);
			try
			{
				OutLineFilter outLineFilter = new OutLineFilter(false);
				foreach (Element element in selection.PickElementsByRectangle(outLineFilter, "选择轮廓线"))
				{
					DetailCurve item = element as DetailCurve;
					outLineList.Add(item);
				}
			}
			catch (Exception)
			{
				return false;
			}
			return true;
		}

		private bool PickPoint(string statusPrompt, ref XYZ ptPick)
		{
			try
			{
				ptPick = this.m_Revit.Application.ActiveUIDocument.Selection.PickPoint(statusPrompt);
			}
			catch (Exception)
			{
				return false;
			}
			return true;
		}

		private bool PickBox(string statusPrompt, ref XYZ ptMin, ref XYZ ptMax)
		{
			try
			{
				PickedBox pickedBox = this.m_Revit.Application.ActiveUIDocument.Selection.PickBox((Autodesk.Revit.UI.Selection.PickBoxStyle)0, statusPrompt);
				ptMin = pickedBox.Min;
				ptMax = pickedBox.Max;
			}
			catch (Exception)
			{
				return false;
			}
			return true;
		}

		private bool PickEdge(ref Curve refCurve)
		{
			Reference reference = null;
			Selection selection = this.m_Revit.Application.ActiveUIDocument.Selection;
			try
			{
				EdgeFilter edgeFilter = new EdgeFilter(this.m_Doc);
				reference = selection.PickObject((Autodesk.Revit.UI.Selection.ObjectType)3, edgeFilter, "选择墙边界生成轮廓线");
			}
			catch (Exception)
			{
				return false;
			}
			if (reference == null)
			{
				return false;
			}
			Edge edge = this.m_Doc.GetElement(reference).GetGeometryObjectFromReference(reference) as Edge;
			if (null == edge)
			{
				return false;
			}
			XYZ globalPoint = reference.GlobalPoint;
			Curve curve = edge.AsCurve();
			refCurve = curve;
			return true;
		}

		public void DrawStartPointTag(XYZ pos)
		{
			this.ClearTagCurves();
			CurveArray curveArray = new CurveArray();
			double num = AssistFunc.mmToFeet(300.0);
			Autodesk.Revit.DB.View activeView = this.m_Doc.ActiveView;
			XYZ startPoint = pos + -num * activeView.RightDirection + num * activeView.UpDirection;
			XYZ endPoint = pos + num * activeView.RightDirection + -num * activeView.UpDirection;
			XYZ startPoint2 = pos + -num * activeView.RightDirection + -num * activeView.UpDirection;
			XYZ endPoint2 = pos + num * activeView.RightDirection + num * activeView.UpDirection;
			Line line = YJKLineEx.YJKGetBound(startPoint, endPoint);
			curveArray.Append(line);
			Line line2 = YJKLineEx.YJKGetBound(startPoint2, endPoint2);
			curveArray.Append(line2);
			Transaction transaction = new Transaction(this.m_Doc);
			try
			{
				transaction.Start("new tag curves");
				foreach (object obj in this.m_Doc.Create.NewDetailCurveArray(this.m_Doc.ActiveView, curveArray))
				{
					DetailCurve detailCurve = (DetailCurve)obj;
					this.m_TagCurves.Add(detailCurve.Id);
				}
				transaction.Commit();
			}
			catch (Exception ex)
			{
				string message = ex.Message;
				if (transaction != null && transaction.HasStarted() && !transaction.HasEnded())
				{
					transaction.RollBack();
				}
			}
		}

		private void DrawLines(List<EdgeInfo> lines)
		{
			List<Element> list = new List<Element>();
			this.DrawLines(lines, ref list);
		}

		private void DrawLines(List<EdgeInfo> lines, ref List<Element> linesList)
		{
			if (lines.Count == 0)
			{
				return;
			}
			Transaction transaction = null;
			try
			{
				transaction = new Transaction(this.m_Doc);
				transaction.Start("draw building outline");
				UIApplication application = this.m_Revit.Application;
				CurveArray curveArray = new CurveArray();
				foreach (EdgeInfo edgeInfo in lines)
				{
					XYZ xyz = edgeInfo.StartPoint;
					if (Geometry.LessThan(xyz.Z, 0.0))
					{
						xyz = new XYZ(xyz.X, xyz.Y, 0.0);
					}
					XYZ xyz2 = edgeInfo.EndPoint;
					if (Geometry.LessThan(xyz2.Z, 0.0))
					{
						xyz2 = new XYZ(xyz2.X, xyz2.Y, 0.0);
					}
					if (!Geometry.IsEqual(xyz.DistanceTo(xyz2), 0.0))
					{
						curveArray.Append(Line.CreateBound(xyz, xyz2));
					}
				}
				DetailCurveArray detailCurveArray = this.m_Doc.Create.NewDetailCurveArray(this.m_Doc.ActiveView, curveArray);
				BuildingOutLineSettingInfo setting = SettingReaderWriter.GetSetting();
				if (this.GetLineStyle(setting))
				{
					List<ElementId> list = new List<ElementId>();
					foreach (object obj in detailCurveArray)
					{
						DetailCurve detailCurve = (DetailCurve)obj;
						detailCurve.LineStyle = BuildingOutlineController.m_LineStyle;
						linesList.Add(detailCurve);
						list.Add(detailCurve.Id);
					}
					LinePatternElement linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, setting.LinePatternName);
					if (linePatternElementByName != null)
					{
						this.m_Doc.ActiveView.SetYJKProjLinePatternOverrideByElement(list, linePatternElementByName);
					}
				}
				transaction.Commit();
			}
			catch (Exception)
			{
				if (transaction != null)
				{
					transaction.RollBack();
				}
			}
		}

		private void DrawLines(List<Curve> lines)
		{
			if (lines.Count == 0)
			{
				return;
			}
			Transaction transaction = null;
			try
			{
				transaction = new Transaction(this.m_Doc);
				transaction.Start("draw building outline");
				UIApplication application = this.m_Revit.Application;
				CurveArray curveArray = new CurveArray();
				foreach (Curve curve in lines)
				{
					curveArray.Append(curve);
				}
				DetailCurveArray detailCurveArray = this.m_Doc.Create.NewDetailCurveArray(this.m_Doc.ActiveView, curveArray);
				BuildingOutLineSettingInfo setting = SettingReaderWriter.GetSetting();
				if (this.GetLineStyle(setting))
				{
					List<ElementId> list = new List<ElementId>();
					foreach (object obj in detailCurveArray)
					{
						DetailCurve detailCurve = (DetailCurve)obj;
						detailCurve.LineStyle = BuildingOutlineController.m_LineStyle;
						list.Add(detailCurve.Id);
					}
					LinePatternElement linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, setting.LinePatternName);
					if (linePatternElementByName != null)
					{
						this.m_Doc.ActiveView.SetYJKProjLinePatternOverrideByElement(list, linePatternElementByName);
					}
				}
				transaction.Commit();
			}
			catch (Exception)
			{
				if (transaction != null)
				{
					transaction.RollBack();
				}
			}
		}

		private bool GetLineStyle(BuildingOutLineSettingInfo setting)
		{
			Category category = this.m_Doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines);
			if (category == null)
			{
				return false;
			}
			int lineWidth = setting.LineWidth;
			string text = BuildingOutlineController.m_StrLineNamePrefix + lineWidth.ToString();
            Autodesk.Revit.DB.Color lineColor = new Autodesk.Revit.DB.Color(0, 0, 0);
			if (!category.SubCategories.Contains(text))
			{
				if (!this.CreateLineStyle(lineWidth, text, lineColor, ref category))
				{
					return false;
				}
			}
			else
			{
				Category category2 = category.SubCategories.get_Item(text);
				category2.LineColor = lineColor;
				category2.SetLineWeight(lineWidth, (Autodesk.Revit.DB.GraphicsStyleType)1);
			}
			foreach (Element element in new FilteredElementCollector(this.m_Doc).OfClass(typeof(GraphicsStyle)))
			{
				GraphicsStyle graphicsStyle = element as GraphicsStyle;
				if (graphicsStyle != null && graphicsStyle.Name.CompareTo(text) == 0)
				{
					BuildingOutlineController.m_LineStyle = graphicsStyle;
				}
			}
			return BuildingOutlineController.m_LineStyle != null;
		}

        private bool CreateLineStyle(int lineWidth, string typeName, Autodesk.Revit.DB.Color lineColor, ref Category lineCategory)
		{
			bool result;
			try
			{
				Category category = this.m_Doc.Settings.Categories.NewSubcategory(lineCategory, typeName);
				category.LineColor = lineColor;
				category.SetLineWeight(lineWidth, (Autodesk.Revit.DB.GraphicsStyleType)1);
				result = true;
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private ExternalCommandData m_Revit;

		private Document m_Doc;

		private static GraphicsStyle m_LineStyle = null;

		public static string m_StrLineNamePrefix = "HYProfileLine";

        public static WindowHandle _hWndRevit = null;

		private List<ElementId> m_TagCurves = new List<ElementId>();

		private XYZ m_PickLastPoint;

		private UIDocument m_uiDoc;

		private DrawJigCurve m_drawJigCurve;
	}
}
